package com.xiaoshuidi.cloud.module.contract.enums.bill;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 费用类型
 */
@Getter
@AllArgsConstructor
public enum OrderFeeSortTypeEnum {
    CYCLE("cycle","周期性费用"),
    ONCE("once","一次性费用"),
    DEPOSIT("deposit","押金费用"),
    METER("meter","抄表费用");
    private final String code;
    private final String name;

    private static Map<String, OrderFeeSortTypeEnum> enumMap = new HashMap<>();
    static {
        OrderFeeSortTypeEnum[] values = OrderFeeSortTypeEnum.values();
        for (OrderFeeSortTypeEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }
    public static OrderFeeSortTypeEnum getEnum(String num){
        return enumMap.get(num);
    }

    public static String getBillTypeEnumByCode(String code) {
        OrderFeeSortTypeEnum[] orderFeeSortTypeEnums = values();
        for (OrderFeeSortTypeEnum billTypeEnum : orderFeeSortTypeEnums) {
            if (billTypeEnum.code==code) {
                return billTypeEnum.code;
            }
        }
        return null;
    }
}
